package com.tcl.logoidentify.log;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import com.tcl.logoidentify.commons.DateUtilsCustom;


public class ResultBILogService {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	public void saveResultLog(ResultLogBO bo) {
		Date datetime = DateUtilsCustom.parseDate(bo.getCreate_time());
		String datehour = DateUtilsCustom.formatDate(datetime, "yyyyMMddHH");
		if (bo.getClient_type() != null) {
			MDC.put("clientType", StringUtils.join(new String[]{bo.getClient_type(), datehour}, "_"));
		}else{
			MDC.put("clientType", StringUtils.join(new String[]{"null", datehour}, "_"));
		}
		logger.info("{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}",
				new Object[] {bo.getCreate_time(),
						bo.getChannel_id(),
						bo.getChannel_code(),
						bo.getChannel_name(),
						bo.getClient_type(),
						bo.getDevice_id(),
						bo.getMac(),
						bo.getHuan_id(),
						bo.getSv(),
						bo.getTerminal_version(),
						bo.getClient_ip(),
						bo.getUser_id(),
						bo.getTime_diff(),
						bo.getClient_create_times(),
						bo.getServer_create_times(),
						bo.getServer_timestamp()});
	}
}
